<template>
  <div>
    <!-- 列表 -->
    <el-table v-loading="loading" :data="datas" :height="height"  @sort-change="sort" style="width: 100%">
      <el-table-column prop="equipment_id" label="设备编号" min-width="100" sortable="custom" />
      <el-table-column prop="group_name" label="分组" min-width="120" sortable="custom" show-overflow-tooltip />
      <el-table-column prop="mobile_model" label="手机型号" min-width="120" sortable="custom" show-overflow-tooltip />
      <el-table-column prop="alias" label="别名" min-width="250" sortable="custom" show-overflow-tooltip />
      <el-table-column prop="equipment_serial_number" label="设备序列号" min-width="160" sortable="custom" />
      <el-table-column prop="activation_code" label="激活码" min-width="160" sortable="custom" />
      <el-table-column prop="auth_time" label="授权时长" min-width="105" sortable="custom" />
    </el-table>

    <!-- 分页 -->
    <pagination v-show="count > 0" :total="count" :page.sync="query.page" :limit.sync="query.limit" @pagination="list"   />
  </div>
</template>

<script>
  import pagination from '@/components/Pagination'
  import screenHeight from '@/utils/screen-height'
  import { list, add, edit} from '@/api/admin/device-group'

  export default {
    name: 'dlist',

    components: {
      pagination,screenHeight
    },

    created() {
      this.height = screenHeight()
      this.list()
    },

    props: {
      gid: Number
    },

    data() {
      return {
        height: 780,
        loading: false,

        datas: [],

        count: 0,
        query: {
          page: 1,
          limit: 15
        },
      }
    },

    methods: {
      list() {
        this.loading = true
        this.query.gid=this.gid
        list(this.query).then(res => {
          this.datas = res.data.list
          this.count = res.data.count
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      },
      // 排序
      sort(sort) {
        this.query.sort_field = sort.prop
        this.query.sort_value = ''
        if (sort.order === 'ascending') {
          this.query.sort_value = 'asc'
          this.list()
        }
        if (sort.order === 'descending') {
          this.query.sort_value = 'desc'
          this.list()
        }
      },
    },


  }
</script>

<style>
</style>
